package homework.api03.exercises01;

import collection.Point;

import java.util.ArrayList;
import java.util.Collection;

public class CollectionDemo3 {
    public static void main(String[] args) {
        //集合仅能保存引用类型元素,并且保存的是元素的地址
        Collection c = new ArrayList();
        //c.add(123);//自动装箱----c.add(Interger.valueOf(123));
        Point p = new Point(1, 2);
        c.add(p);//将p添加到集合c中----实际上是将p的地址保存到集合c中
        System.out.println(p);//(1,2)
        System.out.println(c);//[(1,2)]

        p.setX(100);
        System.out.println(p);//(100,2)
        System.out.println(c);//[(100,2)]
    }
}
